<?php

namespace app\yunda\validate;
use think\Validate;
class Goods extends Validate
{
    //定义验证规则
    protected $rule = [
        'good_name|商品名称' => 'require|max:30',
        'good_type|商品分类' => 'require',
        'good_img|商品图片'  => 'require',
        'need_score|兑换商品积分'  => 'require|regex:^[1-9]\d{1,8}$',
        'stock|库存'  => 'require|regex:^[0-9]\d{0,9}$',
        'sort|排序'  => 'integer',

    ];

    //定义验证提示
    protected $message = [
        'good_name.max' => '商品名称最多30个字符',
        'stock.regex' => '库存必须是非负整数,最多10位',
        'need_score.regex' => '积分必须是非负整数,最多9位',
    ];
}
